/*
 * MCAL_Timer.h
 *
 *  Created on: Sep 26, 2025
 *      Author: ADMIN
 */

#ifndef BSW_MACL_INC_MCAL_TIMER_H_
#define BSW_MACL_INC_MCAL_TIMER_H_


/***********************************************************************************
 ********************************************************************************
 *--------------------------------------------------------------------------
 *                            FILE DESCRIPTION
 *--------------------------------------------------------------------------
 *
 *    File Name    :     MCAL_Timer.h
 *    File Module  :     BSW_MCAL
 *    File Description:  This file is used to define function about Timers
 *
 ********************************************************************************
 ***********************************************************************************/
#include "All_In_One.h"

/* Timers CONTROL STRUCT */
typedef struct HWTimer_ID_Type HWTimer_ID_Type;
struct HWTimer_ID_Type{
	/* SW information */
    TIM_HandleTypeDef* timerhandle;
    uint32 period_cnt;
    uint32 prescale;
    uint32 now_cnt;
	/* Function Index */
	Std_ReturnType (*Start)    (struct HWTimer_ID_Type* tim_num);
    Std_ReturnType (*Stop )    (struct HWTimer_ID_Type* tim_num);
    Std_ReturnType (*CleanCnt) (struct HWTimer_ID_Type* tim_num);
    Std_ReturnType (*GetCnt )  (struct HWTimer_ID_Type* tim_num);
    Std_ReturnType (*Cleanflag)(struct HWTimer_ID_Type* tim_num);
};

/* Timers CONTROL FUNCTION */
Std_ReturnType MCAL_Timer_Init(void);
Std_ReturnType MCAL_Timer_DeInit(void);
Std_ReturnType HW_Timer_Start(HWTimer_ID_Type* tim_num);
Std_ReturnType HW_Timer_Stop(HWTimer_ID_Type* tim_num);
Std_ReturnType HW_Timer_CleanCnt(HWTimer_ID_Type* tim_num);
Std_ReturnType HW_Timer_GetCnt(HWTimer_ID_Type* tim_num);
Std_ReturnType HW_Timer_Cleanflag(HWTimer_ID_Type* tim_num);
void HW_Timer_Creat(HWTimer_ID_Type* tim_num,TIM_HandleTypeDef* timhandle);

/* Be defined GLOABAL HWTimer_ID_Type */
extern HWTimer_ID_Type HWTimer_ID_0x07;
#define RS485_UART_Timer HWTimer_ID_0x07

extern HWTimer_ID_Type HWTimer_ID_0x06;
#define Boot_Status_Timer HWTimer_ID_0x06

extern HWTimer_ID_Type HWTimer_ID_0x09;
#define Cycle_500ms_Timer HWTimer_ID_0x09
#endif /* BSW_MACL_INC_MCAL_TIMER_H_ */
